package org.itboys.member;

import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.itboys.framework.query.JsonPageUtils;
import org.itboys.framework.query.PageQueryUtils;
import org.itboys.framework.spring.controller.BaseController;
import org.itboys.fuzion.dto.PublicRowDto;
import org.itboys.fuzion.mysql.service.PublicRowService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

@RestController 
@RequestMapping("/publicrow") 
public class PublicRowController extends BaseController{

	@Autowired
	private PublicRowService publicRowService;
	
	@RequestMapping("/toListVM")
	public ModelAndView toListVM(HttpServletRequest request, HttpServletResponse response) {
		return new ModelAndView("/member/publicrow");
	}
	
	@RequestMapping("/list")
	public void list(HttpServletRequest request, HttpServletResponse response){
		final Map<String,Object> sqlMap = PageQueryUtils.preparePage(request,20);//组装查询参数
		List<PublicRowDto> prdList = publicRowService.getPublicRowPoolAll(sqlMap);
		long count = publicRowService.count(sqlMap);
		JsonPageUtils.renderJsonPage(count, prdList, response);
	}
}
